home *** CD-ROM | disk | FTP | other *** search
- %OP%JUY
- %OP%DFT
- %OP%TM2
- %OP%BM4
- %OP%LM6
- %CO:A,12,72%
-
-
-
-
-
-
-
-
- Mr Gerald Fitton
- Abacus Training
- 29 Okus Grove
- Upper Stratton
- SWINDON
- Wilts
- SN2 6QA
-
-
- Dear Gerald,
-
- %JR%In reply to your letter about the anagram competition, no I didn't use
- Pipedream macros to find the anagrams, but here is the solution:
-
- 1. Dump the pipedream dictionary to a file called DumpedFile.
-
- %JR%2. Run the following program to sort the letters in each word into
- alphabetical order:
-
- 5 REM >Champ
- 10 in%PC%=OPENIN"Dumpedfile"
- 20 out%PC%=OPENOUT"Words"
- 22 N%PC%=0
- 25 REPEAT
- 30 line$=GET$#in%PC%
- 32 in$=line$
- 35 out$=""
- 40 FOR C%PC%=ASC"a" TO ASC"z"
- 45 C$=CHR$C%PC%
- 50 I%PC%=INSTR(line$,C$)
- 60 IF I%PC%>0 THEN out$=out$+C$:
- line$=LEFT$(line$,I%PC%-1)+MID$(line$,I%PC%+1):
- GOTO50
- 70 NEXT
- 85 N%PC%+=1:
- IF N%PC%MOD100=0 PRINT;N%PC%;TAB(9);in$;TAB(30);out$
- 90 BPUT#out%PC%,out$
- 100 UNTIL EOF#in%PC%
- 110 CLOSE#in%PC%
- 120 CLOSE#out%PC%
-
- %JR%This will change "sort", "rots" and "tors" to "orst" for example, so
- %JR%all anagrams of a particular word will be converted to the same new
- word with all of its letters in alphabetical order.
-
-
-
- %JR%3. Now find the word that occurs most often in the "words" file.
- %JR%There are various Unix and GNU utilities to do this (usually called
- %JR%freq) but the versions I have ran out of memory on my 2Mbyte machine.
- %JR%If you have a 4Mbyte machine you should be able to load the words file
- %JR%into Pipedream to sort it, but again Pipedream ran out of memory trying
- %JR%to load a 900K file even though I had 1300K free after loading
- %JR%Pipedream (presumably Pipedream maintains a lot of pointers and other
- information for every line).
-
- %JR%The solution if you have 2Mbytes (but not 1Mbyte) is to run the
- following Basic program to sort the words:
-
- 10 REM >SORT
- 20 file$="Words"
- 30 F%PC%=OPENIN file$
- 40 ext%PC%=EXT#F%PC%
- 45 CLOSE#F%PC%
- 50 DIM array%PC% ext%PC%+10
- 55 PRINT"Loading words"
- 60 OSCLI "load "+file$+" "+STR$~array%PC%
- 70 DIM ptr%PC% 400000:REM 100,000 words, 4 byte pointer
- 80 wc%PC%=1:
- !ptr%PC%=array%PC%
- 85 PRINT"Building word pointers and terminating with CR chars"
- 90 FOR I%PC%=0 TO ext%PC%-1
- 100 IF array%PC%?I%PC%=10 THEN array%PC%?I%PC%=13:
- ptr%PC%!(wc%PC%<<2)=array%PC%+I%PC%+1:
- wc%PC%+=1
- 110 NEXT
- 115 T%PC%=TIME:
- PRINT"Calling OS HeapSort"
- 120 SYS "OS_HeapSort",wc%PC%,ptr%PC%,4
- 121 PRINT"Sort took ";(TIME-T%PC%)/100;" seconds"
- 125
- 126 out%PC%=OPENOUT"out"
- 130 FOR I%PC%=0 TO wc%PC%-1
- 140 add%PC%=ptr%PC%!(I%PC%<<2)
- 150 BPUT#out%PC%,$add%PC%
- 160 NEXT
- 180 CLOSE#out%PC%
-
- %JR%This takes about 40 seconds to sort the words and save them in the file
- "out".
-
- %JR%4. Now run the following program to find which words have a frequency
- of 5 or more:
-
- 10 REM >Count
- 15 freq%PC%=5
- 20 in%PC%=OPENIN"OUT"
- 26 last$=""
- 27 count%PC%=0
- 30 REPEAT
- 40 word$=GET$#in%PC%
- 50 IF word$=last$ THEN
- 60 count%PC%+=1
- 70 ELSE
- 80 IF count%PC%>=freq%PC% PRINTcount%PC%;CHR$9;last$
- 90 last$=word$:
- count%PC%=1
- 100 ENDIF
- 110
- 120 UNTIL EOF#in%PC%
- 130 CLOSE#in%PC%
-
- %JR%Note that the words this program prints will normally be rubbish words
- %JR%with their letters in alphabetical order. It is usually easy to see
- %JR%at least one anagram of the word (since they all have plenty) but if
- %JR%you can't see it, just type the word into Pipedream's anagram search
- and it will list them all.
-
- Yours sincerely,
-
-
-
- Paul M Skirrow
- %CO:B,12,60%%CO:C,12,48%%CO:D,12,36%%CO:E,12,24%9 Randwell Close
- IPSWICH
- IP4 5ES
-
- Tel. 0473 728943
-
- 19 May 1990
- %CO:F,12,12%